<!doctype html>
<meta charset="utf-8">
<title>HTMLSelectElement.selectedOptions and HTMLSelectElement.value</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#dom-select-value">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>

<select id="sel">
  <option id="opt1" value="x" data-foo="a">1st opt</option>
  <option id="opt2" value="y" data-foo="b">2nd opt</option>
</select>

<script>
  "use strict";
  test(() => {

    const select = document.getElementById("sel");
    const opt1 = document.getElementById("opt1");
    const opt2 = document.getElementById("opt2");

    select.value = "x";
    assert_equals(select.selectedOptions[0], opt1);

    select.value = "y";
    assert_equals(select.selectedOptions[0], opt2);

  }, "`HTMLSelectElement.selectedOptions` is correctly updated when `HTMLSelectElement.value` changes");
</script>
